/**
 *
 * @author John Creecy
 */

package battlebarnserver;

import java.util.Iterator;
import java.util.Map;

public class FlushStaleClients implements Runnable {

	public void run() {
		flushClients();
	}

	private void flushClients() {
			Long currentTime = (long) System.currentTimeMillis();
			Long clientTime;
			String clientId;
			Iterator it = BattleBarn.clientList.entrySet().iterator();
		while (it.hasNext()) {
			Map.Entry mapEntry = (Map.Entry) it.next();
			clientTime = (Long) mapEntry.getValue();
			clientId = (String) mapEntry.getKey();
			if((currentTime - clientTime) > 300000) {
				BattleBarn.clientList.remove(clientId);
			}
		}
	}

}
